package com.cares.core.mng.web;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.cares.core.mng.service.MenuService;
import com.cares.core.mng.service.ShiroDbRealm.ShiroUser;
import com.cares.entity.mng.Menu;

/**
 * 
 * @author T-Moblile
 *
 */
@Controller
@RequestMapping(value = "/Proxy")
public class ProxyController {

	@Autowired
	@Qualifier("menuService")
	MenuService menuService;
	
	@RequestMapping(method=RequestMethod.GET)
	public String mainPage( HttpServletRequest req,
			HttpServletResponse response) {
		Menu menu=new Menu();
		menu.setUpMenuId(new Long(1));
		menu.setAvailable("Y");
		ShiroUser suser = menuService.getCurrentUser();
		if(menuService.getCurrentUser().isSuperMan())
		{
		req.setAttribute("MenuList", menuService.searchMenu(menu));
		}
		else
		{
		menuService.searchAuthMenu(menu);
		req.setAttribute("MenuList",menu.getSubMenuList());
		}
		req.setAttribute("ORG",menuService.getCurrentUser().getOrgName());
		
		return "frm/proxy/mainPage";
	}
	@RequestMapping(value = "monitoring")
	public String monitoring( HttpServletRequest req,
			HttpServletResponse response) {
		Menu menu=new Menu();
		menu.setUpMenuId(new Long(1));
		menu.setAvailable("Y");
		req.setAttribute("MenuList", menuService.searchMenu(menu));
		return "frm/proxy/druid/index";
	}
	
	@RequestMapping(value = "home")
	public String home( HttpServletRequest req,
			HttpServletResponse response) { 
		return "frm/proxy/home";
	}
	
	@RequestMapping(value = "aboutUser")
	public String info( HttpServletRequest req,
			HttpServletResponse response) { 
		return "frm/proxy/user";
	}
	
}
